<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表单元素双向绑定</title>
    <script src="/js/vue.js"></script>
</head>
<body>
    <div id="main">
        <input type="text" v-model="user.id"></input>
        <input type="text" v-model="user.dept.name"></input>

        <button @click="add">添加</button>
    </div>
<script>
    new Vue({
        el: "#main",
        data: {
            user:{
                dept:{

                }
            }
        },
        methods: {
            add(){
                console.log(this.user.id)
                console.log(this.user.dept.name)
            }
        },


    })
</script>
</body>
</html>